import java.util.Arrays;

//消失的数字
public class Code {
    public int missingNumber(int[] nums){
        Arrays.sort(nums);
        if(nums.length == 1){
            if(nums[0] == 1){
                return 0;
            }
            return 1;
        }
        for(int i = 0 ; i < nums.length-1 ; i++){
            if(nums[i+1] - nums[i] == 2){
                return (nums[i+1] + nums[i]) / 2;
            }
        }
        if(nums[0] != 0)
            return 0;
        return nums[nums.length-1] +1;
    }
    public int missingNumber1(int[] nums) {

        int count = 0;
        for(int i = 0 ; i < nums.length; i++){

            if(nums[i] != count){
                return count;
            }
            count++;
        }
        return count+1;
    }
}
